﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Restarty_SIPO3.Class
{
    class Zakaznik
    {
        private string suma;

        public String IDZakaznika { get; set; }
        public String RajonID { get; set; }
        public String Kod { get; set; }
        public String Meno { get; set; }
        public String Priezvisko { get; set; }
        public String Ulica { get; set; }
        public String PSCMesto { get; set; }
        public String KontaktneStredisko { get; set; }
        public String Znamienko { get; set; }

        public String CelkovaSuma
        {
            get
            {
                return suma.Replace(",", ".");
            }
            set
            {
                suma = value;
            }
        }
        public Boolean Restart { get; set; }
        public ArrayList Sluzby { get; set; }

        public Zakaznik()
        {
            Sluzby = new ArrayList();
        }

        internal ArrayList VytvorRetazce(Subor DataSubor)
        {
            String tmpStr = null;
            ArrayList tmpArray = new ArrayList();
            int i = 0;
            foreach (Posta tmpPosta in DataSubor.PolePost)
            {
                foreach (Rajon tmpRajon in tmpPosta.Rajony)
                {
                    foreach (Zakaznik tmpZakaznik in tmpRajon.Zakaznici)
                    {
                        tmpStr += "(''" + tmpZakaznik.IDZakaznika + "'',''" + tmpRajon.IDRajonu + "'',''" + tmpZakaznik.Kod + "'',''" + tmpZakaznik.Meno + "'',''" + tmpZakaznik.Ulica + "'',''" + tmpZakaznik.PSCMesto + "'',''" + tmpZakaznik.KontaktneStredisko + "'',''" + tmpZakaznik.Znamienko + "''," + tmpZakaznik.CelkovaSuma + "),";
                        i++;
                        if (i > 500)
                        {
                            tmpArray.Add(tmpStr.Substring(0, tmpStr.Length - 1));
                            tmpStr = null;
                            i = 0;
                        }
                    }
                    if (tmpStr != null)
                        tmpArray.Add(tmpStr.Substring(0, tmpStr.Length - 1));
                    tmpStr = null;
                    i = 0;
                }
            }
            return tmpArray;
        }
    }
}
